package com.twu.biblioteca;

import java.util.HashMap;

public class UserList {


    private static HashMap<String,User> userList  = new HashMap<String, User>();

    public static boolean has(User user) {
        return userList.containsValue(user) && userList.containsKey(user.libraryNumber());
    }

    public static void add(User user) {
        userList.put(user.libraryNumber(),user);
    }

    public static Boolean authenticateUser(String userLibraryNumber, String password) {
        if(userList.containsKey(userLibraryNumber)){
             User user =getUser(userLibraryNumber);
             return user.comparePasswordWith(password);
        }
        return false;
    }

    public static User getUser(String userLibraryNumber) {
        return userList.get(userLibraryNumber);
    }
}
